<%@page import="com.xnx3.j2ee.Global"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  
<style>
body{
    margin:0px;
    padding:20px;
    display: flex;
}

.comBox{
    padding: 20px;
    border: solid 1px;
    width: calc(25% - 10px);
    margin-right: 20px;
}

body .comBox:nth-child(4n+0){
    margin-right: 0px;
    background-color: crimson;
}

.comBox .title{
    font-size: 20px;
    line-height: 40px;
}

.comBox .optBox{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.comBox .optBox input{
    width: 100%;
    margin-bottom: 20px;
}

.comBox .optBox button{
    width: 60%;
}
</style>

<jsp:include page="/wm/common/head.jsp">
	<jsp:param name="title" value="编辑"/>
</jsp:include>
<!-- <script src="/js/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/area.js" type="text/javascript"></script>
<script src="/js/selectMore.js" type="text/javascript"></script> -->
<link rel="stylesheet" href="/js/components/area.css">

<form class="layui-form opolp" style="padding-top:15%; padding-right:35px;">
	<input type="hidden" name="id" value="${entity.id }" />

	<div class="layui-form-item" style="margin-bottom: 30px;">
		<label class="layui-form-label">代理商名称</label>
		<div class="layui-input-block">
			<input type="text" name="name" class="layui-input"
				value="${entity.name }">
		</div>
	</div>
	<style>
		.opolp{
			width: 100%;
			box-sizing: border-box;
		}
		.comBox{
			border: none;
			width: 100%;
			box-sizing: border-box;
			margin: 0;
			padding: 0;
		}
		.comBox .optBox{
			display: flex;
			justify-content: space-between;
			align-content: center;
			align-items: center;
			margin: 0;
			flex-direction: initial;
		}
		.osldk{
			flex: 0 0 auto;
			text-align: right;
		}
		.losldk{
			margin-bottom: 0;
		    display: flex;
		    justify-content: center;
		    align-content: center;
		    align-items: center;
		}
		.comBox .optBox input{
			margin: 0 10px 0 0;
			display: block;
			flex: 8;
			box-sizing: border-box;
			width: 70%;
			height: 38px;
		    line-height: 1.3;
		    border-width: 1px;
		    border-style: solid;
		    background-color: #fff;
		    border-radius: 2px;
		    border-color: #e6e6e6;
		    padding-left: 10px;
		}
		.comBox .optBox button{
			width: 30%;
			height: 38px;
		    line-height: 1.3;
		    border: none;
		    background-color: #1E9FFF;
		    color: #fff;
		}
		.com-area-float-box{
			max-height:200px;
			padding-tight:5px;
		}
	</style>
	
	<div class="layui-form-item" style="margin-bottom: 30px;">
		<div class="layui-form-item losldk">
			<label class="layui-form-label osldk">服务地区</label>

			<div class="comBox"><!-- 
				<div class="title">区域选择组件</div> -->
				<div class="optBox">
					<input type="text layui-input" placeholder="" id="areaNames" name="areaNames" 
						value="<c:if test="${entity.shi == '全部'}">${entity.sheng }</c:if><c:if test="${entity.shi != '全部' && entity.qu == '全部'}">${entity.shi }</c:if><c:if test="${entity.qu != '全部'}">${entity.qu }</c:if>"/>
					<input type="hidden" id="areaCodes" name="areaCodes" value='${areaCodes}'/>
					<button type="button" id="sltBtn">选择地区</button>
				</div>
			</div>
		</div>
	</div>
	<div class="layui-form-item"style="margin-bottom: 30px;">
		<label class="layui-form-label">负责人</label>
		<div class="layui-input-block">
			<input type="text" name="contactName" class="layui-input" value="${entity.contactName }">
		</div>
	</div>
	<div class="layui-form-item"style="margin-bottom: 30px;">
		<label class="layui-form-label">手机号</label>
		<div class="layui-input-block">
			<input type="number" name="phone" class="layui-input" value="${entity.phone }">
		</div>
	</div>
	
	<div class="layui-form-item"style="margin-bottom: 30px;">
		<label class="layui-form-label">邮箱</label>
		<div class="layui-input-block">
			<input type="text" name="email" class="layui-input" value="${entity.email }">
		</div>
	</div>
   	<div class="layui-form-item" style="padding-top:15px;">
		<div class="layui-input-block">
			<button class="layui-btn" lay-submit="" lay-filter="demo1">保存</button>
		</div>
	</div>
</form>

<script src="/js/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/js/area.js" type="text/javascript"></script>
<!-- <script src="/js/selectMore.js" type="text/javascript"></script> -->
<script>
//自适应弹出层大小
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
//parent.layer.iframeAuto(index);


layui.config({
    base: '/js/components/'
});

layui.use(['form', 'layedit', 'laydate', 'element',"area",], function(){
	var form = layui.form,
		element = layui.element;

	//监听提交
	form.on('submit(demo1)', function(data){
		parent.parent.msg.loading("保存中");
		var postDate = wm.getJsonObjectByForm($("form"));	//提交的表单数据
		wm.post('savev2.json', postDate, function (obj) { 
			parent.parent.msg.close();
			if(obj.result == '1'){
				parent.parent.msg.success("操作成功")
				parent.layer.close(index);
				parent.location.reload();	//刷新父窗口
			}else if(obj.result == '0'){
				parent.parent.msg.failure(obj.info);
			}else{
				parent.parent.msg.failure(result);
			}
		});
	    
		return false;
	});

		$("#sltBtn").click(function() {
			var area = layui.area;
			area.select({
				title : "请选择指定区域",
				url : "/js/components/area_data.json",
				selected : {
					countries : [],
					provinces : [],
					cities : [],
					counties : []
				},//选中回显
				expSelected : {
					countries : [],
					provinces : [],
					cities : [],
					counties : []
				},//需要排除已经选中的
				level : 3,//指定层级(1-省级、2-市级；3-区县)
				selected : {
					countries : [],
					provinces : [${sheng}],
					cities : [${city}],
					counties : [${qu}]
				},//选中回显
				expSelected : {
					countries : [],
					provinces : [],
					cities : [],
					counties : []
				},//需要排除已经选中的
				callback : function(rlt) {
					$("#areaCodes").val(JSON.stringify(rlt.areaCodes));
					$("#areaNames").val(rlt.areaNames);
				}
			});

		});
	});
	function renderForm() {
		layui.use('form', function() {
			var form = layui.form; //高版本建议把括号去掉，有的低版本，需要加()
			form.render();
		});
	}
</script>

<jsp:include page="/wm/common/foot.jsp"></jsp:include> 